package com.gaohe.official.controller;

import java.util.List;
import java.io.IOException;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.gaohe.common.log.annotation.Log;
import com.gaohe.common.log.enums.BusinessType;
import com.gaohe.common.security.annotation.RequiresPermissions;
import com.gaohe.official.domain.FmReport;
import com.gaohe.official.service.IFmReportService;
import com.gaohe.common.core.web.controller.BaseController;
import com.gaohe.common.core.web.domain.AjaxResult;
import com.gaohe.common.core.utils.poi.ExcelUtil;
import com.gaohe.common.core.web.page.TableDataInfo;

/**
 * 内容举报Controller
 * 
 * @author ruoyi
 * @date 2025-06-03
 */
@RestController
@RequestMapping("/report")
public class FmReportController extends BaseController
{
    @Autowired
    private IFmReportService fmReportService;

    /**
     * 查询内容举报列表
     */
    @RequiresPermissions("official:report:list")
    @GetMapping("/list")
    public TableDataInfo list(FmReport fmReport)
    {
        startPage();
        List<FmReport> list = fmReportService.selectFmReportList(fmReport);
        return getDataTable(list);
    }

    /**
     * 导出内容举报列表
     */
    @RequiresPermissions("official:report:export")
    @Log(title = "内容举报", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FmReport fmReport)
    {
        List<FmReport> list = fmReportService.selectFmReportList(fmReport);
        ExcelUtil<FmReport> util = new ExcelUtil<FmReport>(FmReport.class);
        util.exportExcel(response, list, "内容举报数据");
    }

    /**
     * 获取内容举报详细信息
     */
    @RequiresPermissions("official:report:query")
    @GetMapping(value = "/{reportId}")
    public AjaxResult getInfo(@PathVariable("reportId") Long reportId)
    {
        return success(fmReportService.selectFmReportByReportId(reportId));
    }

    /**
     * 新增内容举报
     */
    @RequiresPermissions("official:report:add")
    @Log(title = "内容举报", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FmReport fmReport)
    {
        return toAjax(fmReportService.insertFmReport(fmReport));
    }

    /**
     * 修改内容举报
     */
    @RequiresPermissions("official:report:edit")
    @Log(title = "内容举报", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FmReport fmReport)
    {
        return toAjax(fmReportService.updateFmReport(fmReport));
    }

    /**
     * 删除内容举报
     */
    @RequiresPermissions("official:report:remove")
    @Log(title = "内容举报", businessType = BusinessType.DELETE)
	@DeleteMapping("/{reportIds}")
    public AjaxResult remove(@PathVariable Long[] reportIds)
    {
        return toAjax(fmReportService.deleteFmReportByReportIds(reportIds));
    }
}
